﻿using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using Medicalsystem.MCP.FormDesigner.Common;
using Medicalsystem.MCP.FormDesigner.Interface;
using Medicalsystem.MCP.FormDesigner.Property;

namespace Medicalsystem.MCP.FormDesigner.MyControls
{
    /// <summary>
    ///
    /// </summary>
    public class GetMyTimerProperty : GetCtrlProperty
    {
        /// <summary>
        /// 可视控件属性基类
        /// </summary>
        /// <param name="ctrlUI"></param>
        public GetMyTimerProperty(MyTimer ctrl)
            : base(ctrl)
        {
            _myTimer = ctrl;
        }

        private MyTimer _myTimer = null;

        #region 外观

        /// <summary>
        /// 文本
        /// </summary>
        [CategoryAttribute("外观")]
        [ShowChinese("文本")]
        [Description("控件文本")]
        [EditorAttribute(typeof(ContentEditorDropDown), typeof(System.Drawing.Design.UITypeEditor))]
        public string ShowText
        {
            get
            {
                return _myTimer.ShowText;
            }
            set
            {
                _myTimer.ShowText = value;
            }
        }

        #endregion 外观

        /// <summary>
        /// 设置控件属性
        /// </summary>
        /// <param name="propertyName"></param>
        /// <param name="value"></param>
        public override void SetProperty(string propertyName, object value)
        {
            switch (propertyName.ToLower())
            {
                case "width":
                    this._control.Width = (int)value;
                    break;

                case "height":
                    this._control.Height = (int)value;
                    break;

                case "top":
                    this._control.Top = (int)value;
                    break;

                case "left":
                    this._control.Left = (int)value;
                    break;

                case "anchor":
                    this._control.Anchor = (AnchorStyles)value;
                    break;

                case "dock":
                    this._control.Dock = (DockStyle)value;
                    break;

                case "backcolor":
                    this._control.BackColor = (Color)value;
                    break;

                case "forecolor":
                    this._control.ForeColor = (Color)value;
                    break;

                case "showtext":
                    (this._control as ICtrlUI).ShowText = value.ToString();
                    break;

                case "font":
                    this._control.Font = (Font)value;
                    break;

                case "visiblez":
                    (this._control as ICtrlUI).VisibleZ = (bool)value;
                    break;

                case "borderstylez":
                    (this._control as ICtrlUI).BorderStyleZ = (EBorderStyle)value;
                    break;
                default:
                    base.SetProperty(propertyName, value);
                    break;
            }
        }
    }
}